Skip to content

Conversation

@lewis-wow
Copy link
Contributor

@lewis-wow lewis-wow commented Nov 27, 2025

This PR introduces simple new parseBooleanOrNull utility function to parse boolean from string.
If value is stringbool, then the function return true/false.
if the value is invalid, then the function return null, which is I think the best as we can distinguish between valid and invalid input, but also null is falsy value, so we can use it as false in condition.

In many repos, we do not use Zod validator which can handle this using coerce api, and it would be a very heavy dependency for just this usecase.

@lewis-wow lewis-wow added the adhoc Ad-hoc unplanned task added during the sprint. label Nov 27, 2025
@github-actions github-actions bot added t-core-services Issues with this label are in the ownership of the core services team. tested Temporary label used only programatically for some analytics. labels Nov 27, 2025
@jirimoravcik
Copy link
Member

Also relevant for MCP as we recently added the same function there https://github.com/apify/apify-mcp-server/blob/master/src/utils/generic.ts#L75

@jirispilka

Copy link
Member

@valekjo valekjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I'd add an issue to replace the parseBooleanParameter in the API

Copy link
Member

@jirimoravcik jirimoravcik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-core-services Issues with this label are in the ownership of the core services team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants